package com.example.yiqiuser.controller;
import com.example.yiqiuser.entity.Season;
import com.example.yiqiuser.entity.Theme;
import com.example.yiqiuser.service.ThemeService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @create by: 周文达 (3220083246@qq.com)
 * @description: 主题栏目(TDicTheme)表控制层
 * @create time: 2023/4/12 22:43
 * @return
 */
@RestController
@RequestMapping("theme")
public class ThemeController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ThemeService themeService;

    /**
     * 分页查询
     *
     * @param筛选条件
     * @param page      分页对象
     * @return 查询结果
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Theme> page){
        return success(themeService.queryPage(page));
    }



    /**
     * 新增数据
     *
     * @param theme 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public  Result add(@RequestBody Theme theme){
        return success(themeService.add(theme));
    }

    /**
     * 更改
     * @param theme
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody Theme theme){
        return success(themeService.update(theme));
    }

    /**
     * 查询全部
     * @return
     */
    @PostMapping("queryAll")
    public  Result queryAll(){
        return success(themeService.queryAll());
    }

    /**
     * 根据id查询
     * @param code
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer code){
        return success(themeService.queryById(code));
    }

    /**
     * 删除数据
     *
     * @param code 主键
     * @return 删除是否成功
     */
    @GetMapping("deleteById")
    public Result deleteById(Integer code){
        return success(themeService.deleteById(code));
    }

}

